package com.hustbaidu.hustmap;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;

public class PathPointView extends View {
	private int width, height;
	private int offsetX, offsetY;
	private Bitmap mBitmap;

	public PathPointView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public PathPointView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public PathPointView(Context context, int icon_id) {
		super(context);
		// TODO Auto-generated constructor stub
		mBitmap = BitmapFactory.decodeResource(getResources(), icon_id);
		this.width = mBitmap.getWidth();
		this.height = mBitmap.getHeight();
//		this.setBackgroundResource(icon_id);
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
//		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		setMeasuredDimension(width, height);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
//		System.out.println(offsetX + " : " + offsetY);
		canvas.drawBitmap(mBitmap, 0, 0, null);
	}
	
	public void setPositionInfo(int offsetX, int offsetY){
		this.offsetX = offsetX;
		this.offsetY = offsetY;
	}
	
	public void move(int distanceX, int distanceY){
		offsetX = offsetX - distanceX;
		offsetY = offsetY - distanceY;
	}

	public int getOffsetX() {
		return offsetX;
	}

	public int getOffsetY() {
		return offsetY;
	}

	public int getWidthProperty() {
		return width;
	}

	public int getHeightProperty() {
		return height;
	}
	
	

}
